<?php


namespace app\admin\model;


use app\common\BaseModel;

class MessageModel extends BaseModel
{
    protected $table = 'blog_admin_message';

    /**
     * 关联文章
     * @return \think\model\relation\HasOne
     */
    public function article() {
        return $this->hasOne(ArticleModel::class, 'id', 'article_id');
    }

    /**
     * 更新阅读状态
     * @param int $messageId
     */
    public function updateMessageToReadById(int $messageId) {
        self::update([
            'id' => $messageId,
            'read_status' => 1,
            'status' => 1,
        ]);
    }
}